package top.kaoshanji.p2ch16b;

import top.kaoshanji.p2ch16a.IWomen;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * 代码清单-p2ch16b-185页b：场景类
 * @author kaoshanji
 * ^_^
 * create time 2025/3/23 19:25
 */
public class Client {

    public static void main(String[] args) {

        // 随机挑选几个女性
        Random rand = new Random();
        List<IWomen> list = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            list.add(new Women(rand.nextInt(4), "我要出去逛街"));
        }

        // 定义三个请示对象
        Handler father = new Father();
        Handler husband = new Husband();
        Handler son = new Son();

        // 设置请示顺序
        father.setNext(husband);
        husband.setNext(son);

        for (IWomen women: list) {
            father.handleMessage(women);
        }

    }

}
